package com.augurit.wf.app.document.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.augurit.common.syscode.service.ISysCodeService;
import com.augurit.wf.app.document.dao.DocConfigDao;
import com.augurit.wf.app.document.entity.DocConfig;
import com.augurit.wf.app.document.service.IDocConfigService;
import com.augurit.wf.app.document.utils.StatApplicationContextUtils;

@Service
@Transactional
public class DocConfigServiceImpl implements IDocConfigService {
	
	@Autowired
	private DocConfigDao docConfigDao;
	
	@Autowired
	private ISysCodeService sysCodeService; 
	
	public DocConfig findConfigByName(String name) {
		// TODO Auto-generated method stub
		return docConfigDao.findConfigByName(name);
	}

	public List<DocConfig> findConfigByType(String type) {
		// TODO Auto-generated method stub
		return docConfigDao.findConfigByType(type);
	}

	public String findParamsName(String key) {
		// TODO Auto-generated method stub
		
		Map<String, String> paramsMap = StatApplicationContextUtils.getParameterMap();//CodeUtils.buildCodeMap(sysCodeService.getItems("ASTAT_SYS_PARAMETERS"));		
		Object obj = paramsMap.get(key);
		if(obj != null){
			return obj.toString();
		}
		return null;
	}
	
	public String find101Table() {
		// TODO Auto-generated method stub
		if(this.T_101 == null){
			return StatApplicationContextUtils.get101TabName();
			/*
			HashMap<String, String> paramsMap = CodeUtils.buildCodeMap(sysCodeService.getItems("ASTAT_SYS_TABLE"));		
			Object obj = paramsMap.get("SYS_T_101");
			if(obj != null){
				return obj.toString();
			}
			return null;
			*/
		}
		return this.T_101;
		
	}

	public String findDZMTable() {
		// TODO Auto-generated method stub
		if(this.T_DZM == null){
			return StatApplicationContextUtils.get102TabName();
			/*
			HashMap<String, String> paramsMap = CodeUtils.buildCodeMap(sysCodeService.getItems("ASTAT_SYS_TABLE"));		
			Object obj = paramsMap.get("SYS_T_102");
			if(obj != null){
				return obj.toString();
			}
			return null;
			*/
		}
		return this.T_DZM;
	}

}
